package com.ysc.chessfightbackend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * Version: 1.0
 * Class Name: Knife4jConfiguration
 * Description: TODO(一句话描述功能)
 * Author: ysc
 * Date: 2024/5/15 9:53
 */

@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfiguration {

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        Docket docket=new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                //分组名称
                .groupName("1.0")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.ysc"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("摄影作品分享网")  //标题
                .contact(new Contact("ysc","http://116.205.143.25","abcdefg@qq.com"))  //作者
                .description("摄影作品分享网")  //简介
                .termsOfServiceUrl("http://116.205.143.25") //服务URL
                .version("1.0") //版本
                .build();
    }
}
